package com.vitaf.cash.app.sdk.analyse.bean

import com.vitaf.cash.app.sdk.analyse.GombeCreditAnalyseBuilder
import com.vitaf.cash.app.sdk.analyse.GombeCreditAnalyseUtil
import com.google.gson.Gson

open class GombeCreditBaseBean(
    var token: String = "",
    var userId: String = "",
    var androidId: String = "",
    var advertId: String = "",
    var version: String = "",
    var product: String = "",
    var clientType: String = "",
    var aduid: String = "",
    var aduidPath: String = "",
    var isLimitAdTrackingEnabled: String = "",
    val apiVersion: String = "v3",
    var path: String = ""
) {
    init {
        this.token = GombeCreditAnalyseBuilder.token
        this.userId = GombeCreditAnalyseBuilder.userId
        this.version = GombeCreditAnalyseBuilder.libVersion
        this.product = GombeCreditAnalyseBuilder.product
        this.isLimitAdTrackingEnabled = GombeCreditAnalyseUtil.getAdEnabled().toString()
        this.androidId = GombeCreditAnalyseUtil.getAndroidId()
        this.advertId = GombeCreditAnalyseUtil.getAdId()
        this.aduid = GombeCreditAnalyseUtil.getAdId()
        this.aduidPath = GombeCreditAnalyseUtil.getAndroidId()
        this.clientType = "ANDROID"
    }

    /**
     * 根据path生成加密参数
     *
     * @param path 接口路径
     */
    open fun encrypt(path: String): String {
        this.path = path.replace("/", "")
        if (path.isBlank()) return ""

        return Gson().toJson(this).trim()
    }
}